<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">
  <meta name="format-detection" content="telephone=no">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>设置密码</title>
  <script>
      (function () {
          var setFont=function () {
              var calc_window_width=window.innerWidth>750?750:window.innerWidth;
              document.documentElement.style.fontSize=calc_window_width/7.5+'px';
          }
          setFont();
          window.onresize=function () {
              setFont();
          }
      })()
  </script>
  <link rel="stylesheet" href="css/icon.css">
  <link rel="stylesheet" href="css/weui.css">
  <link rel="stylesheet" href="css/jquery-weui.css">
  <link rel="stylesheet" href="css/style.css">
</head>
<body>
  <!-- 顶部部分 -->
  <div class="weui-header bg_blue"> 
    <div class="weui-header-left">
      <a class="icon icon-109 f-white"></a>  
    </div>
    <h1 class="weui-header-title">设置密码</h1>
  </div>
  <section>
    <div class="bg-f5 space20"></div>
    <div class="set-pwd-box">
      <p>设置密码</p>
      <span>密码由8-16位数字、字母或符号组成</span>
      <div class="pwd-ipt">
        <input class="password1" type="password" placeholder="请设置密码">
        <div class="select select1"></div>
      </div>
      <div class="pwd-ipt">
        <input class="password2" type="password" placeholder="请再次确认">
        <div class="select select2"></div>
      </div>
    </div>
    <div class="btn_box set-pwd-next-btn-box">
      <a href="javascript:;" class="weui-btn next">下一步</a>
    </div>
  </section>

  <script src="script/jquery-2.2.4.js"></script>
  <script src="script/jquery-weui.js"></script>
  <script src="script/js.js?1"></script>
  <script>
    var mobile=GetQueryString('mobile');
    $('.password1').on('input',function(){
      var password1=$(this).val();
      if(password1.match(/^[0-9a-zA-Z~!@&$%^*()_#]{8,16}$/)){
        $('.pwd-ipt .select1').css({
          'background-color':'transparent',
          'background-image': 'url(image/select-onbg.png)',
        })
        $('.password2').on('input',function(){
          if($(this).val()==password1){
            $('.pwd-ipt .select2').css({
              'background-color':'transparent',
              'background-image': 'url(image/select-onbg.png)',
            })
          }else{
            $('.pwd-ipt .select2').css({
              'background-color':'#EAEAEA',
              'background-image': 'url()',
            })
          }
        })
      }else{
        $('.pwd-ipt .select1').css({
          'background-color':'#EAEAEA',
          'background-image': 'url()',
        })
      }
    })
    $('.next').click(function(){
      var password1=$('.password1').val();
      var password2=$('.password2').val();
      if(password1.match(/^[0-9a-zA-Z~!@&$%^*()_#]{8,16}$/)){
        if(password1==password2){
          $.ajax({
            url:ajaxUrl+'/api/login/register',
            data:{
              mobile:mobile,
              password:password1,
              referee:GetQueryString('id'),
              agent_id:'',
            },
            type:'post',
            dataType:'json',
            success:function(data){
              if(data.code==200){data.username
                window.location='register-suc.html?username='+data.data.username;
              }else{
                $.alert(data.msg);
              }
            },
            error:function(err){
              $.alert(err.msg);
            }
          })
        }else{
          $.alert('前后输入不一致！')
        }
      }else{
        $.alert('密码由8-16位数字、字母或符号组成！')
      }
    })
  </script>
</body>
</html>
